package April._30.answer.work3;

import java.util.ArrayList;
import java.util.Iterator;

public class Main {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("ls");
        list.add("zs");
        list.add("ls");
        list.add("zs");
        list.add("zs");

        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()){
            String next = iterator.next();
            if (list.indexOf(next) != list.lastIndexOf(next)){
                iterator.remove();
            }
        }

        System.out.println(list);
    }
}
